package com.bigShen.pattern.singleton.lazy;

/**
 * @Auther: lei.shen
 * @Date: 2018/10/1 16:24
 * @Description:
 * 使用内部类
 */
public class LazyTwo {

    private Boolean initialize = Boolean.FALSE;

    private LazyTwo() {

        synchronized (LazyTwo.class) {
            if (!initialize) {
                initialize = !initialize;
            } else {
                throw  new RuntimeException("实例被侵犯!");
            }
        }

    }

    public static LazyTwo getInstance() {
        return InnerClass.SINGLETON;
    }

    private static class InnerClass {
       private static final LazyTwo SINGLETON = new LazyTwo();
    }

}
